home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Apple Macintosh Developer Technical Support
- **
- ** Common routines for dispatching for any sound component
- **
- ** by Mark Cookson, Apple Developer Technical Support
- **
- ** File: ComponentDispatch.c
- **
- ** Copyright ©1996 Apple Computer, Inc.
- ** All rights reserved.
- **
- ** You may incorporate this sample code into your applications without
- ** restriction, though the sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. However, what you are
- ** not permitted to do is to redistribute the source as "Apple Sample
- ** Code" after having made changes. If you're going to re-distribute the
- ** source, we require that you make it clear in the source that the code
- ** was descended from Apple Sample Code, but that you've made changes.
- */
-
- #include "ComponentDispatch.h"
-
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // Sound Component Entry Point
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- #if !GENERATINGPOWERPC
- pascal ComponentResult SoundComponentEntryPoint(ComponentParameters *params, SoundComponentGlobalsPtr globals);
- pascal ComponentResult SoundComponentEntryPoint(ComponentParameters *params, SoundComponentGlobalsPtr globals)
- #else
- static pascal ComponentResult SoundComponentProc(ComponentParameters *params, SoundComponentGlobalsPtr globals);
- RoutineDescriptor SoundComponentEntryPoint = BUILD_ROUTINE_DESCRIPTOR(uppSoundComponentEntryPointProcInfo, SoundComponentProc);
- static pascal ComponentResult SoundComponentProc(ComponentParameters *params, SoundComponentGlobalsPtr globals)
- #endif
- {
- ComponentResult result;
- short selector = params->what;
-
- if (selector < 0)
- switch (selector - kComponentRegisterSelect) // standard component selectors
- {
- case kComponentRegisterSelect - kComponentRegisterSelect:
- result = CallComponentFunctionWithStorageUniv((Handle) globals, params, __SoundComponentRegister);
- break;
-
- case kComponentVersionSelect - kComponentRegisterSelect:
- return (kSoundComponentVersion);
- break;
-
- case kComponentCanDoSelect - kComponentRegisterSelect:
- result = __SoundComponentCanDo(0, *((short *) ¶ms->params[0]));
- break;
-
- case kComponentCloseSelect - kComponentRegisterSelect:
- result = CallComponentFunctionWithStorageUniv((Handle) globals, params, __SoundComponentClose);
- break;
-
- case kComponentOpenSelect - kComponentRegisterSelect:
- result = CallComponentFunctionWithStorageUniv((Handle) globals, params, __SoundComponentOpen);
- break;
-
- default:
- result = badComponentSelector;
- break;
- }
- else if (selector < kDelegatedSoundComponentSelectors) // selectors that cannot be delegated
- switch (selector)
- {
- case kSoundComponentSetSourceSelect:
- result = CallComponentFunctionWithStorageUniv((Handle) globals, params, __SoundComponentSetSource);
- break;
-
- case kSoundComponentGetSourceDataSelect:
- result = CallComponentFunctionWithStorageUniv((Handle) globals, params, __SoundComponentGetSourceData);
- break;
-
- case kSoundComponentSetOutputSelect:
- result = CallComponentFunctionWithStorageUniv((Handle) globals, params, __SoundComponentSetOutput);
- break;
-
- default:
- result = badComponentSelector;
- break;
- }
- else // selectors that can be delegated
- switch (selector)
- {
- case kSoundComponentGetInfoSelect:
- result = CallComponentFunctionWithStorageUniv((Handle) globals, params, __SoundComponentGetInfo);
- break;
-
- case kSoundComponentStopSourceSelect:
- result = CallComponentFunctionWithStorageUniv((Handle) globals, params, __SoundComponentStopSource);
- break;
-
- case kSoundComponentPlaySourceBufferSelect:
- result = CallComponentFunctionWithStorageUniv((Handle) globals, params, __SoundComponentPlaySourceBuffer);
- break;
-
- default:
- result = DelegateComponentCall(params, globals->sourceComponent);
- break;
- }
-
- return (result);
- }
-
-
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static pascal ComponentResult __SoundComponentCanDo(void *unused1, short selector)
- {
- #pragma unused (unused1)
-
- ComponentResult result;
-
- switch (selector)
- {
- case kComponentRegisterSelect:
- case kComponentVersionSelect:
- case kComponentCanDoSelect:
- case kComponentCloseSelect:
- case kComponentOpenSelect:
- case kSoundComponentSetSourceSelect:
- case kSoundComponentGetSourceSelect:
- case kSoundComponentGetSourceDataSelect:
- case kSoundComponentSetOutputSelect:
- // selectors that can be delegated
- case kSoundComponentGetInfoSelect:
- case kSoundComponentStopSourceSelect:
- case kSoundComponentPlaySourceBufferSelect:
- result = true;
- break;
-
- default:
- result = false;
- break;
- }
-
- return (result);
- }
-
-